<extend name="Public:base" />
<block name="content">
	<form id="validation-form" method="post">
    <style type="text/css">
        li{
            list-style: none;;
        }
		table{
			text-align: center;
		}
		.mytableer tbody > tr > td{
			border: none;
		}
    </style>
<div class="table-responsive">
	<table class="table table-striped table-bordered table-hover search-form" id="nav-table">
		<thead>
	    <th>时间：<input id="startDate" name="start_time" value="{:I('start_time')}" class="Wdate" type="text" onfocus="WdatePicker({dateFmt:'yyyy-M-d 00:00:00'})"/>- <input id="endDate" name="end_time" value="{:I('end_time')}" class="Wdate" type="text" onfocus="WdatePicker({dateFmt:'yyyy-M-d 00:00:00'})"/>

	    姓名：<input name="name" type="text" placeholder="" value="{:I('name')}" style="width:90px;" />

	    手机号：<input name="phone" type="text" placeholder="" value="{:I('phone')}" style="width:90px;" />
				<a class="btn btn-primary btn-sm radius5" href="javascript:;" id="search" url="{:U('User/Manage')}">查询</a>
			</th>
		<th>订单总数：{$count} 单 总金额：{$total} 元</th>
		</thead>
	</table>
</div>
</form>
<div class="table-responsive">
	<table class="table table-striped table-bordered table-hover" id="mytable">
		<thead>
			<tr>
				<th>头像</th>
				<th>账号</th>
				<th>姓名</th>
				<th>地址</th>
				<th>注册时间</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
				<volist name="user" id="vo">
				<tr>
					<td><img src="{$vo.user_face}"/></td>
					<td><span>{$vo.phone}</span><br>
						<span>（邀请码：<php>echo empty($vo['invite_code'])?无:$vo['invite_code']</php>)</span><br>
						<php>if($vo['user_status']=='3'){</php>
						<span class="btn btn-xs btn-info radius5">加锁</span>&nbsp;<span class="btn btn-xs btn-info radius5">黑名单</span>
						<php>}else{</php>
						<span class="btn btn-xs btn-info radius5"><php>echo $vo['user_status']==0?正常:($vo['user_status']==1?加锁:($vo['user_status']==2?黑名单:false))</php></span>
						<php>}</php>
					</td>
					<td>{$vo.user_name}</td>
					<td><php>if(empty($vo['address'])){</php>
						默认地址：暂无
						<php>}else{</php>
						默认地址：{$vo.address}
						<php>}</php></td>
					<td>{$vo.add_time}</td>
					<td>
						<table class="mytableer">
							<tr><td><a href="{:U('User/info')}/user_id/{$vo.user_id}" class="btn btn-xs btn-info radius5">基本信息</a></td><td><a href="{:U('Order/Index')}/user_phone/{$vo.phone}" class="btn btn-xs btn-info radius5 order">订单管理</a></td><td><a href="{:U('Coupon/CouponUseInfo')}/user_phone/{$vo.phone}" class="btn btn-xs btn-info radius5 preferential">查看优惠券</a></td></tr>
							<tr><td><a href="{:U('User/address')}/user_id/{$vo.user_id}" class="btn btn-xs btn-info radius5 defaultAdress">地址管理</a></td><td><php>if($vo['user_status']=='0'){</php><button onclick='black("{$vo.user_id}")' class="btn btn-xs btn-info radius5">加黑名单</button></td><td><button onclick='lock("{$vo.user_id}")' class="btn btn-xs btn-info radius5">锁定</button><php>}elseif($vo['user_status']=='1'){</php><button onclick='addblack("{$vo.user_id}")' class="btn btn-xs btn-info radius5">加黑名单</button></td><td><button onclick='restorelock("{$vo.user_id}")' class="btn btn-xs btn-info radius5"><span style="color: #000000;">解除锁定</span></button><php>}elseif($vo['user_status']=='2'){</php><button onclick='restoreblack("{$vo.user_id}")' class="btn btn-xs btn-info radius5"><span style="color: red;">解除黑名单</span></button></td><td><button onclick='addblock("{$vo.user_id}")' class="btn btn-xs btn-info radius5">锁定</button><php>}elseif($vo['user_status']==3){</php><button onclick='cancelblack("{$vo.user_id}")' class="btn btn-xs btn-info radius5"><span style="color: red;">解除黑名单</span></button></td><td><button onclick='cancellock("{$vo.user_id}")' class="btn btn-xs btn-info radius5"><span style="color: #000000;">解除锁定</span></button><php>}</php></td></tr>
						</table>
					</td>
					</tr>
				</volist>
				<tr>
					<td colspan="20" class="page">{$page}</td>
				</tr>
		</tbody>
	</table>
</div>
</block>
<block name="javascript">
<script>
$(function() {

	// $(".order").click(function(){
	// 	sessionStorage.setItem("text","维修订单");
	// });

	// $(".preferential").click(function(){
	// 	sessionStorage.setItem("text","电子券使用情况");
	// });

	// $(".defaultAdress").click(function(){
	// 	sessionStorage.setItem("text","用户地址");
	// });


	$("#search").click(function () {
		var url = $(this).attr('url');
		var query = $('.search-form').find('input,select').serialize();
		query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
		query = query.replace(/^&/g, '');
		if (url.indexOf('?') > 0) {
			url += '&' + query;
		} else {
			url += '?' + query;
		}
		window.location.href = url;
	});

});

function black($user_id){
	$.ajax({
		url:"{:U('User/blacklist')}",
		type:"post",
		data:{user_id:$user_id},
		success:function(data){
			if(data=='1'){
				$.jbox.tip("正在修改数据...", 'loading');
				// 模拟2秒后完成操作
				window.setTimeout(function () { $.jbox.tip('修改成功！', 'success');location.reload()}, 1000);
			}else{
				$.jbox.info("修改失败!",'提示');
			}
		}
	});
}

function lock($user_id){
	$.ajax({
		url:"{:U('User/lock')}",
		type:"post",
		data:{user_id:$user_id},
		success:function(data){
			if(data=='1'){
				$.jbox.tip("正在修改数据...", 'loading');
				// 模拟2秒后完成操作
				window.setTimeout(function () { $.jbox.tip('修改成功！', 'success');location.reload()}, 1000);
			}else{
				$.jbox.info("修改失败!",'提示');
			}
		}
	});
}

function addblack($user_id){
	$.ajax({
		url:"{:U('User/blacklist')}",
		type:"post",
		data:{user_id:$user_id},
		success:function(data){
			if(data=='1'){
				$.jbox.tip("正在修改数据...", 'loading');
				// 模拟2秒后完成操作
				window.setTimeout(function () { $.jbox.tip('修改成功！', 'success');location.reload()}, 1000);
			}else{
				$.jbox.info("修改失败!",'提示');
			}
		}
	});
}

function restorelock($user_id){
	$.ajax({
		url:"{:U('User/lock')}",
		type:"post",
		data:{user_id:$user_id,
			  restore:1},
		success:function(data){
			if(data=='1'){
				$.jbox.tip("正在修改数据...", 'loading');
				// 模拟2秒后完成操作
				window.setTimeout(function () { $.jbox.tip('修改成功！', 'success');location.reload()}, 1000);
			}else{
				$.jbox.info("修改失败!",'提示');
			}
		}
	});
}

function restoreblack($user_id){
	$.ajax({
		url:"{:U('User/blacklist')}",
		type:"post",
		data:{user_id:$user_id,
			restore:1},
		success:function(data){
			if(data=='1'){
				$.jbox.tip("正在修改数据...", 'loading');
				// 模拟2秒后完成操作
				window.setTimeout(function () { $.jbox.tip('修改成功！', 'success');location.reload()}, 1000);
			}else{
				$.jbox.info("修改失败!",'提示');
			}
		}
	});
}

function addblock($user_id){
	$.ajax({
		url:"{:U('User/lock')}",
		type:"post",
		data:{user_id:$user_id},
		success:function(data){
			if(data=='1'){
				$.jbox.tip("正在修改数据...", 'loading');
				// 模拟2秒后完成操作
				window.setTimeout(function () { $.jbox.tip('修改成功！', 'success');location.reload()}, 1000);
			}else{
				$.jbox.info("修改失败!",'提示');
			}
		}
	});
}

function cancelblack($user_id){
	$.ajax({
		url:"{:U('User/blacklist')}",
		type:"post",
		data:{user_id:$user_id,
			restore:1},
		success:function(data){
			if(data=='1'){
				$.jbox.tip("正在修改数据...", 'loading');
				// 模拟2秒后完成操作
				window.setTimeout(function () { $.jbox.tip('修改成功！', 'success');location.reload()}, 1000);
			}else{
				$.jbox.info("修改失败!",'提示');
			}
		}
	});
}

function cancellock($user_id){
	$.ajax({
		url:"{:U('User/lock')}",
		type:"post",
		data:{user_id:$user_id,
			restore:1},
		success:function(data){
			if(data=='1'){
				$.jbox.tip("正在修改数据...", 'loading');
				// 模拟2秒后完成操作
				window.setTimeout(function () { $.jbox.tip('修改成功！', 'success');location.reload()}, 1000);
			}else{
				$.jbox.info("修改失败!",'提示');
			}
		}
	});
}
</script>
</block>